var app = angular.module("app",[]);

app.controller('SignController',['$scope',function ($scope) {
    $scope.userData = {};
    $scope.submitForm = function () {
      console.log($scope.userData);
        if($scope.signForm.$invalid){
            alert('请检查！')
        }else{
            alert("success!");
        }
    };
}]);

app.directive('compare',function () {
    return{
        restrict:"AE",
        require:'ngModel',
        scope:{
            oldVal : '=compare'
        },
        link:function (scope,element,attrs,ngmodel) {
            console.log(ngmodel);
            ngmodel.$validators.compare = function (v) {
                return v == scope.oldVal;
            }
            scope.$watch('oldVal',function () {
                ngmodel.$validate();
            });

        }
    }
});

